-
Notifications
You must be signed in to change notification settings - Fork 1.8k
implemented inheritance of 3 classes and methods as well #2433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
All core requirements are fully met: Machine
is abstract with the required public abstract methods, Truck
/Bulldozer
/Excavator
correctly extend and override them, and MainApp
demonstrates polymorphism by iterating a Machine[]
and calling doWork()
/stopWork()
. Functionality compiles and runs; no blockers or broken behavior detected.
However, there are minor checklist style issues with redundant empty lines that you should fix next:
Machine.java
: remove the blank line after thepackage
(line 2) and the blank line between the two abstract method declarations (around line 5).Truck.java
: remove the blank line after thepackage
and the blank line betweendoWork()
and@Override
ofstopWork()
.Excavator.java
: remove the blank line between the closing brace ofdoWork()
and the@Override
ofstopWork()
(currently around line 8).MainApp.java
: remove the unnecessary blank lines insidemain
.
Optional polish: unify punctuation/phrasing in Bulldozer
messages (avoid double dots and add a period to stopWork()
), and consider using an enhanced for-loop in MainApp
. Nice work overall—just tidy the whitespace to align with the checklist.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
public void doWork() { | ||
System.out.println("Excavator is started working..."); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violates the checklist item: "Please don't add redundant empty lines to your code.\nWe don't need them after class declaration or method signature." Remove the blank line between the closing brace of doWork()
and the @Override
of stopWork()
so the methods follow one another without an extra empty line (the blank is currently on line 8). See checklist for guidance .
@@ -0,0 +1,7 @@ | |||
package core.basesyntax; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has a redundant empty line between the package statement and the class declaration. The checklist explicitly says: "Please don't add redundant empty lines to your code." Consider removing this blank line so the class declaration immediately follows the package line. See checklist: "Please don't add redundant empty lines to your code."
|
||
public abstract class Machine { | ||
public abstract void doWork(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This empty line between the two abstract method declarations is redundant. The checklist guidance states: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove this blank line so the method declarations are adjacent and follow the style guidance .
Machine truck = new Truck(); | ||
Machine bullDozer = new Bulldozer(); | ||
Machine excavator = new Excavator(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Violation — redundant empty line
This line is an unnecessary blank line inside the main
method. It violates the checklist item: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Consider removing this blank line to match the project style guidelines.
Machine excavator = new Excavator(); | ||
|
||
Machine[] arrayOfMachines = {truck, bullDozer, excavator}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Violation — redundant empty line
This line is another unnecessary blank line inside the main
method. It also violates: "Please don't add redundant empty lines to your code. We don't need them after class declaration or method signature." Remove this blank line to comply with the checklist.
@@ -0,0 +1,13 @@ | |||
package core.basesyntax; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains an extra blank line immediately after the package
declaration. The project checklist says: "Please don't add redundant empty lines to your code." Removing this blank line will make the file consistent with the style guidance and examples in the checklist. See checklist: "We don't need them after class declaration or method signature."
public void doWork() { | ||
System.out.println("Truck is started working..."); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a redundant empty line between the end of doWork()
and the next @Override
. The checklist warns: "We don't need them after class declaration or method signature." Consider removing this blank line so method blocks follow one another directly, matching the recommended style.
No description provided.